package com.to8to.thrift.esb.async.example.server;

import java.util.Map;

import com.to8to.kitt.ThriftBizServerChannelInitializer;
import com.to8to.kitt.asyc.AsyncBizChannelHandler;
import com.to8to.kitt.esb.DefaultServerDeamon;
import com.to8to.kitt.esb.NodeChangeEvent;
import com.to8to.thrift.esb.async.example.ServiceA;


public class ServerA extends DefaultServerDeamon{

	@Override
	public void onPrivateConfigChange(Map<String, NodeChangeEvent> config) {
		
		String[] files = {serverFile};
		
		for(String file: files)
		{
			NodeChangeEvent event = config.get(file);
			
			if (event == null) {
				logger.warn("服务配置找不到: " + file);
				continue;
			}
			
			if(!event.isChange())
			{
				System.out.println("服务地址配置不变:server.properties, 忽略之!");
				continue;
			}
			
			byte[] data = event.ndata;
		
			
		}
		
		super.onPrivateConfigChange(config);
	}

	@Override
	public void onCommonConfigChange(NodeChangeEvent e) {
		if(!e.isChange())
			return;
		
		
	}
	
	public static void main(String[] args) {
		
		ServiceA_Handler handler = new ServiceA_Handler();
		
		AsyncBizChannelHandler bizhandler = new AsyncBizChannelHandler(handler);
		
		ThriftBizServerChannelInitializer channelInitilizer = new ThriftBizServerChannelInitializer(bizhandler);
		
		ServerA s = new ServerA();
		
		s.setSyncConfigFromZK(true);
		
		s.setReportAddressToZK(true);
		
		s.setChannelInitilizer(channelInitilizer);
		
		s.setServiceInstance(ServiceA.class.getName(), "1");
		
		s.init();
	}


}
